<template>
  <div class="update-main">
    <div class="update-title">
      <h2>更新日志</h2>
    </div>
    <div class="time-line" v-loading="loading">
      <el-timeline>
        <el-timeline-item
          v-for="list in lists"
          :key="list.id"
          :timestamp="list.date"
          placement="top"
        >
          <el-card>
            <h4>{{ list.info }}</h4>
            <p>{{ list.content }}</p>
          </el-card>
        </el-timeline-item>
      </el-timeline>
    </div>
          <div class="page-box">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="pageSize"
          layout="prev, pager, next"
          :total="total"
        >
        </el-pagination>
      </div>
  </div>
</template>

<script>
export default {
  name: "UpdateLog",
  data() {
    return {
      loading: true,
      currentPage: 1,
      total: 0,
      page: 1,
      pageSize: 10,
      pageNum: 1,
      lists: []
    };
  },
  methods: {
    //获取列表数据
    getList: function() {
      let para = {
        pageNum: this.pageNum,
        pageSize: this.pageSize
      };
      this.loading = true;
// /back/front/
// /api/
      this.$axios.get("/back/front/updatelog/listByPage",{ params: para }).then(res => {
        let resData = res.data;
        if (resData.code === 200) {
          this.lists = resData.data.records;
          this.total = resData.data.total;
          this.currentPage = this.pageNum;
          this.loading = false;
        } else {
          this.loading = false;
          this.$message({
            message: resData.message,
            type: "error"
          });
        }
      });
    },
    //改变时
    handleSizeChange(val) {
      this.pageSize = val;
      this.getList();
    },
    //条目改变时
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getList();
    }
  },
  created() {
    this.getList();
  }
};
</script>

<style lang="scss" scoped>
.update-main {
  margin: 0 auto;
  padding: 20px;
  background: #fff;
  .update-title {
    text-align: center;
    margin-bottom: 40px;
  }
  ::v-deep .el-loading-spinner .path {
    stroke: #41b883;
  }
  .time-line {
    padding-right: 350px;
  }
      .page-box {
      text-align: center;
      ::v-deep .el-pager {
        li {
          &:hover {
            color: #41b883;
          }
          &.active {
            background-color: #41b883;
            &:hover {
              color: #fff;
            }
          }
        }
      }
    }
}
</style>
